<?php
define('IN_SCRIPT',1);
define('HESK_PATH','./');

/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/database.inc.php');

hesk_dbConnect();

global $hesk_settings, $hesklang;

hesk_session_start();
if ($hesk_settings['secimg_use'])
{
	$_SESSION['secnum']=rand(10000,99999);
	$_SESSION['checksum']=sha1($_SESSION['secnum'].$hesk_settings['secimg_sum']);
}

/* Print header */
$hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' . $hesklang['register'];
require_once(HESK_PATH . 'inc/header.inc.php');
?>

<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td><span class="smaller"><a href="<?php echo $hesk_settings['site_url']; ?>" class="smaller"><?php echo $hesk_settings['site_title']; ?></a> &gt; <a href="<?php echo $hesk_settings['hesk_url']; ?>" class="smaller"><?php echo $hesk_settings['hesk_title']; ?></a> &gt; <?php echo $hesklang['docregister']; ?></span></td>
  </tr>
</table>
    
<?php /* This will handle error, success and notice messages */
hesk_handle_messages();
?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="7" height="7"><img src="img/roundcornerslt.jpg" width="7" height="7" alt="" /></td>
        <td class="roundcornerstop"></td>
        <td><img src="img/roundcornersrt.jpg" width="7" height="7" alt="" /></td>
      </tr>
      <tr>
        <td class="roundcornersleft">&nbsp;</td>
        <td><!-- START FORM -->
          <p><?php echo $hesklang['use_form_docregister']; ?></p>
          <form method="post" action="register_doc_account.php" name="form1" enctype="multipart/form-data">
            <table border="0" width="100%">
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['email']; ?>:</td>
                <td width="80%"><input type="text" name="email" size="40" maxlength="50" value="<?php if (isset($_SESSION['c_email'])) {echo stripslashes(hesk_input($_SESSION['c_email']));} ?>" /></td>
              </tr>
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['password']; ?>:</td>
                <td width="80%"><input type="password" name="password" size="40" maxlength="50" value="" /></td>
              </tr>
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['repass']; ?>:</td>
                <td width="80%"><input type="password" name="repass" size="40" maxlength="50" value="" /></td>
              </tr>
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['profile_pic']; ?>:</td>
                <td width="80%"><input type="file" name="profpic" size="40" /></td>
              </tr>
              <tr>
                <td style="text-align:right" width="150"></td>
                <td width="80%">Maximum size 50 Kb (jpg)</td>
              </tr>
            </table>
            <hr />
            <!-- Department and priority -->
            <table border="0" width="100%">
               <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['firstname']; ?>:</td>
                <td width="80%"><input type="text" name="firstname" size="40" maxlength="50" value="<?php if (isset($_SESSION['c_firstname'])) {echo stripslashes(hesk_input($_SESSION['c_firstname']));} ?>" /></td>
               </tr>
               <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['lastname']; ?>:</td>
                <td width="80%"><input type="text" name="lastname" size="40" maxlength="50" value="<?php if (isset($_SESSION['c_lastname'])) {echo stripslashes(hesk_input($_SESSION['c_lastname']));} ?>" /></td>
               </tr>
               <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['gender']; ?>:</td>
                <td width="80%">
                    <select name="gender">
                        <option value="1" <?php if(isset($_SESSION['c_gender'])) { echo ($_SESSION['c_gender'] == 1) ? 'selected="selected"' : ''; };?> ><?php echo $hesklang['male'];?></option>
                        <option value="2" <?php if(isset($_SESSION['c_gender'])) { echo ($_SESSION['c_gender'] == 2) ? 'selected="selected"' : ''; };?> ><?php echo $hesklang['female'];?></option>
                    </select>
               </tr>
               <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['handphone']; ?>:</td>
                <td width="80%"><input type="text" name="handphone" size="40" maxlength="50" value="<?php if (isset($_SESSION['c_handphone'])) {echo stripslashes(hesk_input($_SESSION['c_handphone']));} ?>" /></td>
               </tr> 
            </table>
            <hr />
            <table border="0" width="100%">
                <tr>
                    <td style="text-align:right" width="150"><?php echo $hesklang['province']; ?>:</td>
                    <td width="80%">
                        <select name="province" onchange="update_city('<?php echo HESK_PATH; ?>',this.options[this.selectedIndex].value)">
                            <?php
                            $query = 'SELECT * FROM hesk_propinsi';
                            $result = hesk_dbQuery($query);
                            while ($prov = hesk_dbFetchAssoc($result)) {
                                ?>
                                <option value="<?php echo $prov['id_propinsi']; ?>" <?php if (isset($_SESSION['c_province'])) {echo ($_SESSION['c_province'] == $prov['id_propinsi']) ? 'selected="selected"' : '';} ?> >
                                    <?php echo $prov['propinsi']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </td>
                </tr>  
                <tr>
                    <td style="text-align:right" width="150"><?php echo $hesklang['city']; ?>:</td>
                    <td width="80%">
                        <select id="city-selection" name="city">
                            <?php
                            if(isset($_SESSION['c_province'])){
                                $id_province = $_SESSION['c_province'];
                            } else {
                                $id_province = 7;
                            }
                            $query = 'SELECT * FROM hesk_kota WHERE id_propinsi=' . $id_province;
                            $result = hesk_dbQuery($query);
                            while ($city = hesk_dbFetchAssoc($result)) {
                                ?>
                                <option value="<?php echo $city['id_kota']; ?>" <?php if (isset($_SESSION['c_city'])) {echo ($_SESSION['c_city'] == $city['id_kota']) ? 'selected="selected"' : '';} ?> >
                                    <?php echo $city['kota']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </td>
                </tr>
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['address']; ?>: </td>
                <td width="80%"><input type="text" name="address" size="40" maxlength="50" value="<?php if (isset($_SESSION['c_address'])) {echo stripslashes(hesk_input($_SESSION['c_address']));} ?>" /></td>
               </tr>
            </table>
            <hr />
            <table border="0" width="100%">
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['practice_site']; ?>:</td>
                <td width="80%"><input type="text" name="practice_site" size="40" maxlength="50" value="<?php if (isset($_SESSION['c_practice_site'])) {echo stripslashes(hesk_input($_SESSION['c_practice_set']));} ?>" /></td>
              </tr>
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['kkiregnum']; ?>:</td>
                <td width="80%"><input type="text" name="kkiregnum" size="40" maxlength="50" value="<?php if (isset($_SESSION['c_kkiregnum'])) {echo stripslashes(hesk_input($_SESSION['c_kkiregnum']));} ?>" /></td>
               </tr>  
              <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['sipregnum']; ?>:</td>
                <td width="80%"><input type="text" name="sipregnum" size="40" maxlength="50" value="<?php if (isset($_SESSION['c_sipregnum'])) {echo stripslashes(hesk_input($_SESSION['c_sipregnum']));} ?>" /></td>
               </tr>  
               <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['doc_graduate']; ?>:</td>
                <td width="80%"><input type="text" name="doc_graduate" size="40" maxlength="50" value="<?php if (isset($_SESSION['c_doc_graduate'])) {echo stripslashes(hesk_input($_SESSION['c_doc_graduate']));} ?>" /></td>
               </tr> 
               <tr>
                <td style="text-align:right" width="150"><?php echo $hesklang['specialisation']; ?>:</td>
                <td width="80%"><input type="text" name="specialisation" size="40" maxlength="50" value="<?php if (isset($_SESSION['c_specialisation'])) {echo stripslashes(hesk_input($_SESSION['c_specialisation']));} ?>" /></td>
               </tr>
               <tr>
                <td valign="top" width="200" style="text-align:right"><?php echo $hesklang['signature_max']; ?>:</td>
                <td><textarea name="signature" rows="6" cols="40"><?php if (isset($_SESSION['c_signature'])) {echo $_SESSION['c_signature'];} ?></textarea><br />
                <?php echo $hesklang['sign_extra']; ?></td>
               </tr>
            </table>
                <hr />
            <?php
                        if ($hesk_settings['question_use'] || $hesk_settings['secimg_use'])
                        {
            ?>
            <!-- Security checks -->
            <div align="center">
              <table border="0">
                <tr>
                  <td>
                    <?php
                        if ($hesk_settings['question_use'])
                        {
                                $value = '';
                                if (isset($_SESSION['c_question']))
                                {
                                        $value = stripslashes(hesk_input($_SESSION['c_question']));
                                }
                                echo '<p>'.$hesk_settings['question_ask'].' <font class="important">*</font><br /><input type="text" name="question" size="10" value="'.$value.'"  /></p>';
                        }

                        if ($hesk_settings['secimg_use'])
                        {
                                echo '<p><img src="print_sec_img.php?'.rand(10000,99999).'" width="150" height="40" alt="'.$hesklang['sec_img'].'" border="1" /><br />'.
                                $hesklang['sec_enter'].': <font class="important">*</font> <input type="text" name="mysecnum" size="10" maxlength="5" /></p>';
                        }
                        ?>
                  </td>
                </tr>
              </table>
            </div>
            <hr />
            <?php
                        }
                        ?>
            <!-- Submit -->
            <div align="center">
              <table border="0">
                <tr>
                  <td>
                    <p align="center">
                      <input type="hidden" name="token" value="<?php hesk_token_echo(); ?>" />
                      <input type="submit" value="<?php echo $hesklang['register']; ?>" class="orangebutton"  onmouseover="hesk_btn(this,'orangebuttonover');" onmouseout="hesk_btn(this,'orangebutton');" />
                    </p>
                  </td>
                </tr>
              </table>
            </div>
          </form>
          <!-- END FORM --></td>
        <td class="roundcornersright">&nbsp;</td>
      </tr>
      <tr>
        <td><img src="img/roundcornerslb.jpg" width="7" height="7" alt="" /></td>
        <td class="roundcornersbottom"></td>
        <td width="7" height="7"><img src="img/roundcornersrb.jpg" width="7" height="7" alt="" /></td>
      </tr>
</table>
